package com.xoa.service.rms.impl;

import com.xoa.dao.WFE.WFEFormTypeMapper;
import com.xoa.dao.enclosure.AttachmentMapper;
import com.xoa.dao.rms.RmsFileMapper;
import com.xoa.dao.rms.RmsRollMapper;
import com.xoa.dao.work.WorkMapper;
import com.xoa.dao.workflow.FlowRunMapper;
import com.xoa.dao.workflow.FlowTypeModelMapper;
import com.xoa.model.enclosure.Attachment;
import com.xoa.model.rms.RmsFileWithBLOBs;
import com.xoa.model.rms.RmsRollWithBLOBs;
import com.xoa.model.users.Users;
import com.xoa.model.workflow.FlowFormType;
import com.xoa.model.workflow.FlowRun;
import com.xoa.model.workflow.FlowRunLog;
import com.xoa.service.WFE.WFELog.WFELog;
import com.xoa.service.enclosure.EnclosureService;
import com.xoa.service.rms.RmsFileService;
import com.xoa.util.*;
import com.xoa.util.common.StringUtils;
import com.xoa.util.common.log.FileUtils;
import com.xoa.util.common.session.SessionUtils;
import com.xoa.util.netdisk.ZipUtils;
import com.xoa.util.page.PageParams;
import org.apache.commons.io.IOUtils;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * Created by Administrator on 2017/12/26.
 */
@Service
public class RmsFileServiceImpl implements RmsFileService {

    @Autowired
    private RmsFileMapper rmsFileMapper;

    @Autowired
    private RmsRollMapper rmsRollMapper;

    @Autowired
    private AttachmentMapper attachmentMapper;

    @Autowired
    private WFEFormTypeMapper wfeFormTypeMapper;

    @Autowired
    private FlowRunMapper flowRunMapper;

    @Autowired
    private FlowTypeModelMapper flowTypeModelMapper;

    @Autowired
    private WorkMapper workMapper;

    @Autowired
    private WFELog wfeLog;


    @Override
    public ToJson<RmsFileWithBLOBs> save(RmsFileWithBLOBs rmsFileWithBLOBs, HttpServletRequest request) {
        ToJson<RmsFileWithBLOBs> json = new ToJson<RmsFileWithBLOBs>();
        try {
            Cookie redisSessionId = CookiesUtil.getCookieByName(request,"redisSessionId");
            Users user = SessionUtils.getSessionInfo(request.getSession(), Users.class, new Users(),redisSessionId);
            rmsFileWithBLOBs.setAddUser(user.getUserId());
            rmsFileWithBLOBs.setAddTime(new Date());
            if(rmsFileWithBLOBs.getRollId()==null||rmsFileWithBLOBs.getRollId()==0){
                json.setFlag(1);
                json.setMsg("请选择案卷");
            }
            rmsFileMapper.insertSelective(rmsFileWithBLOBs);
            json.setFlag(0);
            json.setMsg("ok");
            //添加归档日志
            HttpServletRequest request1 = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            FlowRunLog flowRunLog = wfeLog.getFlowRunLogByRequest(request1);
            flowRunLog.setRunId(rmsFileWithBLOBs.getRunId());
            flowRunLog.setType(Constant.TYPE5);
            wfeLog.addFlowRunLog(flowRunLog);
        } catch (Exception e) {
            e.printStackTrace();
            json.setFlag(1);
            json.setMsg("err");
        }
        return json;
    }

    @Override
    public ToJson<RmsFileWithBLOBs> update(RmsFileWithBLOBs rmsFileWithBLOBs, HttpServletRequest request) {
        ToJson<RmsFileWithBLOBs> json = new ToJson<RmsFileWithBLOBs>();
        try {
            Cookie redisSessionId = CookiesUtil.getCookieByName(request,"redisSessionId");
            Users user = SessionUtils.getSessionInfo(request.getSession(), Users.class, new Users(),redisSessionId);
            rmsFileWithBLOBs.setModTime(new Date());
            rmsFileWithBLOBs.setModUser(user.getUserId());
            rmsFileMapper.updateByPrimaryKeySelective(rmsFileWithBLOBs);
            json.setFlag(0);
            json.setMsg("ok");
        } catch (Exception e) {
            e.printStackTrace();
            json.setFlag(1);
            json.setMsg("err");
        }
        return json;
    }

    @Override
    public ToJson<RmsFileWithBLOBs> destroy(String fileIds, HttpServletRequest request) {
        ToJson<RmsFileWithBLOBs> json = new ToJson<RmsFileWithBLOBs>();
        try {
            Cookie redisSessionId = CookiesUtil.getCookieByName(request,"redisSessionId");
            Users user = SessionUtils.getSessionInfo(request.getSession(), Users.class, new Users(),redisSessionId);
            if (!StringUtils.checkNull(fileIds)) {
                rmsFileMapper.destroy(fileIds.split(","), user.getUserId(), new Date());
            }
            json.setFlag(0);
            json.setMsg("ok");
        } catch (Exception e) {
            e.printStackTrace();
            json.setFlag(1);
            json.setMsg("err");
        }
        return json;
    }

    @Override
    public ToJson<RmsFileWithBLOBs> query(RmsFileWithBLOBs rmsFileWithBLOBs, PageParams pageParams) {
        ToJson<RmsFileWithBLOBs> json = new ToJson<RmsFileWithBLOBs>();
        try {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("page", pageParams);

            map.put("fileCode", rmsFileWithBLOBs.getFileCode());
            map.put("fileSubject", rmsFileWithBLOBs.getFileSubject());

            map.put("fileTitle", rmsFileWithBLOBs.getFileTitle());
            map.put("fileTitle0", rmsFileWithBLOBs.getFileTitle0());

            map.put("sendUnit", rmsFileWithBLOBs.getSendUnit());
            map.put("sendDate", rmsFileWithBLOBs.getSendDate());
            map.put("sendDate2", rmsFileWithBLOBs.getSendDate2());

            map.put("roomId", rmsFileWithBLOBs.getRoomId());
            map.put("rollId", rmsFileWithBLOBs.getRollId());

            map.put("secret", rmsFileWithBLOBs.getSecret());
            map.put("urgency", rmsFileWithBLOBs.getUrgency());

            map.put("fileType", rmsFileWithBLOBs.getFileType());
            map.put("fileKind", rmsFileWithBLOBs.getFileKind());

            map.put("filePage", rmsFileWithBLOBs.getFilePage());
            map.put("filePage2", rmsFileWithBLOBs.getFilePage2());
            map.put("printPage", rmsFileWithBLOBs.getPrintPage());
            map.put("printPage2", rmsFileWithBLOBs.getPrintPage2());

            map.put("remark", rmsFileWithBLOBs.getRemark());

            map.put("delStatus", rmsFileWithBLOBs.getDelStatus());

            List<RmsFileWithBLOBs> query = rmsFileMapper.query(map);
            json.setObj(query);
            json.setTotleNum(pageParams.getTotal());
            json.setFlag(0);
            json.setMsg("ok");
        } catch (Exception e) {
            e.printStackTrace();
            json.setFlag(1);
            json.setMsg("err");
        }
        return json;
    }

    @Override
    public ToJson<RmsFileWithBLOBs> leaderQuery(RmsFileWithBLOBs rmsFileWithBLOBs,String room, String roll, String sendUnit, String rollName, String file, PageParams pageParams) {
        ToJson<RmsFileWithBLOBs> json = new ToJson<RmsFileWithBLOBs>();
        try {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("page", pageParams);
            map.put("room",room);
            map.put("roll",roll);
            map.put("sendUnit",sendUnit);
            map.put("rollName",rollName);
            map.put("file",file);
            List<RmsFileWithBLOBs> query = rmsFileMapper.leaderQuery(map);
            json.setObj(query);
            json.setTotleNum(pageParams.getTotal());
            json.setFlag(0);
            json.setMsg("ok");
        } catch (Exception e) {
            e.printStackTrace();
            json.setFlag(1);
            json.setMsg("err");
        }
        return json;
    }

    @Override
    public ToJson<RmsFileWithBLOBs> selectById(Integer fileId, HttpServletRequest request) {
        ToJson<RmsFileWithBLOBs> json = new ToJson<RmsFileWithBLOBs>();
        try {
            RmsFileWithBLOBs rmsFileWithBLOBs = rmsFileMapper.selectByPrimaryKey(fileId);
            List<Attachment> attachmentList = new ArrayList<Attachment>();
            List<Attachment> attachmentLists = new ArrayList<Attachment>();
            if (!StringUtils.checkNull(rmsFileWithBLOBs.getAttachmentId())) {
                String[] ids = rmsFileWithBLOBs.getAttachmentId().split(",");
                //先获取一遍所有附件，获取id  判断是什么文件下的  workflow/roll
                attachmentList = GetAttachmentListUtil.returnAttachment(rmsFileWithBLOBs.getAttachmentName(), rmsFileWithBLOBs.getAttachmentId(),  "xoa" + (String) request.getSession().getAttribute("loginDateSouse"), GetAttachmentListUtil.MODULE_ROLL_MANAGE);
                for (Attachment attachment:attachmentList){
                    Attachment att = attachmentMapper.selectByPrimaryKey(attachment.getAid());
                    if ("2".equals(att.getModule().toString())){
                        attachmentLists.add(GetAttachmentListUtil.returnAttachment(att.getAttachName(), att.getAttachId(), "xoa" + (String) request.getSession().getAttribute("loginDateSouse"), GetAttachmentListUtil.MODULE_WORKFLOW).get(0));
                    }
                    if ("17".equals(att.getModule().toString())){
                        attachmentLists.add(GetAttachmentListUtil.returnAttachment(att.getAttachName(), att.getAttachId(),  "xoa" + (String) request.getSession().getAttribute("loginDateSouse"), GetAttachmentListUtil.MODULE_ROLL_MANAGE).get(0));
                    }
                    if ("0".equals(att.getModule().toString())){
                        attachmentLists.add(GetAttachmentListUtil.returnAttachment(att.getAttachName(), att.getAttachId(),  "xoa" + (String) request.getSession().getAttribute("loginDateSouse"), GetAttachmentListUtil.RMS_FILE).get(0));
                    }
                }


            }
            rmsFileWithBLOBs.setAttachmentList(attachmentLists);

            List<Attachment> attachmentList2 = new ArrayList<Attachment>();
            List<Attachment> attachmentLists2 = new ArrayList<Attachment>();
            if (!StringUtils.checkNull(rmsFileWithBLOBs.getAttachmentId2())) {
                String[] ids = rmsFileWithBLOBs.getAttachmentId().split(",");
                //先获取一遍所有附件，获取id  判断是什么文件下的  workflow/roll
                attachmentList2 = GetAttachmentListUtil.returnAttachment(rmsFileWithBLOBs.getAttachmentName2(), rmsFileWithBLOBs.getAttachmentId2(),  "xoa" + (String) request.getSession().getAttribute("loginDateSouse"), GetAttachmentListUtil.MODULE_ROLL_MANAGE);
                for (Attachment attachment:attachmentList2){
                    Attachment att = attachmentMapper.selectByPrimaryKey(attachment.getAid());
                    if ("2".equals(att.getModule().toString())){
                        attachmentLists2.add(GetAttachmentListUtil.returnAttachment(att.getAttachName(), att.getAttachId(), "xoa" + (String) request.getSession().getAttribute("loginDateSouse"), GetAttachmentListUtil.MODULE_WORKFLOW).get(0));
                    }
                    if ("17".equals(att.getModule().toString())){
                        attachmentLists2.add(GetAttachmentListUtil.returnAttachment(att.getAttachName(), att.getAttachId(),  "xoa" + (String) request.getSession().getAttribute("loginDateSouse"), GetAttachmentListUtil.MODULE_ROLL_MANAGE).get(0));
                    }
                    if ("0".equals(att.getModule().toString())){
                        attachmentLists2.add(GetAttachmentListUtil.returnAttachment(att.getAttachName(), att.getAttachId(),  "xoa" + (String) request.getSession().getAttribute("loginDateSouse"), GetAttachmentListUtil.RMS_FILE).get(0));
                    }
                }


            }
            /*List<Attachment> endList2 = new ArrayList<Attachment>();

            boolean flag = false;
            int i = 0;
            int j = 0;
            for (Attachment attachment:attachmentList2){   //公文去重
                i++;
                for (Attachment att:attachmentList2){
                    j++;
                    if(i==j){
                    continue;
                    }
                    if (!att.getAttachName().equals(attachment.getAttachName())){//名字不相同
                        flag = true;
                    }
                }
                if (!flag) {
                    endList2.add(attachment);
                }

            }*/

            rmsFileWithBLOBs.setAttachmentList2(attachmentLists2);

            json.setObject(rmsFileWithBLOBs);
            json.setFlag(0);
            json.setMsg("ok");
        } catch (Exception e) {
            e.printStackTrace();
            json.setFlag(1);
            json.setMsg("err");
        }
        return json;
    }

    @Override
    public ToJson<RmsFileWithBLOBs> importFile(HttpServletRequest request, HttpServletResponse response, MultipartFile file) {
        ToJson<RmsFileWithBLOBs> json = new ToJson<RmsFileWithBLOBs>();
        InputStream in=null;
        try {
            //判读当前系统
            //读取配置文件
            ResourceBundle rb = ResourceBundle.getBundle("upload");
            String osName = System.getProperty("os.name");
            StringBuffer path = new StringBuffer();
             StringBuffer buffer=new StringBuffer();
        if(osName.toLowerCase().startsWith("win")){
            //sb=sb.append(rb.getString("upload.win"));
            //判断路径是否是相对路径，如果是的话，加上运行的路径
            String uploadPath = rb.getString("upload.win");
            if(uploadPath.indexOf(":")==-1){
                //获取运行时的路径
                String basePath = this.getClass().getClassLoader().getResource(".").getPath()+ File.pathSeparator;
                //获取截取后的路径
                String str2 = "";
                if(basePath.indexOf("/xoa")!=-1){
                    //获取字符串的长度
                    int length = basePath.length();
                    //返回指定字符在此字符串中第一次出现处的索引
                    int index = basePath.indexOf("/xoa");
                    //从指定位置开始到指定位置结束截取字符串
                    str2=basePath.substring(0,index);
                }
                path = path.append(str2 + "/xoa");
            }
            path.append(uploadPath);
            buffer=buffer.append(rb.getString("upload.win"));
        }else{
            path=path.append(rb.getString("upload.linux"));
            buffer=buffer.append(rb.getString("upload.linux"));
        }
            // 判断是否为空文件
            if (file.isEmpty()) {
                json.setMsg("请上传文件！");
                json.setFlag(1);
                return json;
            } else {
                String fileName = file.getOriginalFilename();
                if (fileName.endsWith(".xls") || fileName.endsWith(".xlsx")) {
                    String uuid = UUID.randomUUID().toString().replaceAll("-", "");
                    int pos = fileName.indexOf(".");
                    String extName = fileName.substring(pos);
                    String newFileName = uuid + extName;
                    File dest = new File(path.toString(), newFileName);
                    file.transferTo(dest);
                    // 将文件上传成功后进行读取文件
                    // 进行读取的路径
                    String readPath = path.append(System.getProperty("file.separator")).append(newFileName).toString();
                    in = new FileInputStream(readPath);
                    HSSFWorkbook excelObj = new HSSFWorkbook(in);
                    HSSFSheet sheetObj = excelObj.getSheetAt(0);
                    HSSFRow row = sheetObj.getRow(0);
                    int colNum = row.getPhysicalNumberOfCells();
                    int lastRowNum = sheetObj.getLastRowNum();
                    RmsFileWithBLOBs rmsFileWithBLOBs = null;
                    List<RmsFileWithBLOBs> list = new ArrayList<RmsFileWithBLOBs>();
                    for (int i = 1; i <= lastRowNum; i++) {
                        row = sheetObj.getRow(i);
                        if (row != null) {
                            rmsFileWithBLOBs = new RmsFileWithBLOBs();
                            for (int j = 0; j < colNum; j++) {
                                Cell cell = row.getCell(j);
                                if (cell != null) {
                                    switch (j) {
                                        case 0:
                                            cell.setCellType(CellType.STRING);
                                            rmsFileWithBLOBs.setFileCode(cell.getStringCellValue());
                                            break;
                                        case 1:
                                            rmsFileWithBLOBs.setFileSubject(cell.getStringCellValue());
                                            break;
                                        case 2:
                                            rmsFileWithBLOBs.setFileTitle(cell.getStringCellValue());
                                            break;
                                        case 3:
                                            rmsFileWithBLOBs.setFileTitle0(cell.getStringCellValue());
                                            break;
                                        case 4:
                                            rmsFileWithBLOBs.setSendUnit(cell.getStringCellValue());
                                            break;
                                        case 5:
                                            rmsFileWithBLOBs.setSendDate(cell.getDateCellValue());
                                            break;
                                        case 6:
                                            // 密级 (1-普密,4-秘密,3-机密,2-绝密)
                                            if ("普密".equals(cell.getStringCellValue())) {
                                                rmsFileWithBLOBs.setSecret("1");
                                            } else if ("秘密".equals(cell.getStringCellValue())) {
                                                rmsFileWithBLOBs.setSecret("4");
                                            } else if ("机密".equals(cell.getStringCellValue())) {
                                                rmsFileWithBLOBs.setSecret("3");
                                            } else if ("绝密".equals(cell.getStringCellValue())) {
                                                rmsFileWithBLOBs.setSecret("2");
                                            } else {
                                                rmsFileWithBLOBs.setSecret("1");
                                            }
                                            break;
                                        case 7:
                                            // 紧急等级(1-员工类型,2-普级)
                                            if ("员工类型".equals(cell.getStringCellValue())) {
                                                rmsFileWithBLOBs.setUrgency("1");
                                            } else if ("普级".equals(cell.getStringCellValue())) {
                                                rmsFileWithBLOBs.setUrgency("2");
                                            }
                                            break;
                                        case 8:
                                            // 文件分类(1-公文,2-资料)
                                            if ("公文".equals(cell.getStringCellValue())) {
                                                rmsFileWithBLOBs.setFileType("1");
                                            } else if ("资料".equals(cell.getStringCellValue())) {
                                                rmsFileWithBLOBs.setFileType("2");
                                            }
                                            break;
                                        case 9:
                                            // 公文类别(1-A,2-B,3-C,4-D)
                                            if ("A".equals(cell.getStringCellValue())) {
                                                rmsFileWithBLOBs.setFileKind("1");
                                            } else if ("B".equals(cell.getStringCellValue())) {
                                                rmsFileWithBLOBs.setFileKind("2");
                                            } else if ("C".equals(cell.getStringCellValue())) {
                                                rmsFileWithBLOBs.setFileKind("3");
                                            } else if ("D".equals(cell.getStringCellValue())) {
                                                rmsFileWithBLOBs.setFileKind("4");
                                            }
                                            break;
                                        case 10:
                                            rmsFileWithBLOBs.setFilePage(cell.getStringCellValue());
                                            break;
                                        case 11:
                                            rmsFileWithBLOBs.setPrintPage(cell.getStringCellValue());
                                            break;
                                        case 12:
                                            rmsFileWithBLOBs.setRemark(cell.getStringCellValue());
                                            break;
                                        case 13:
                                            // 所属案卷名称
                                            String rollName = cell.getStringCellValue().trim();
                                            List<RmsRollWithBLOBs> rmsRollWithBLOBs = rmsRollMapper.selectByName(rollName);
                                            if (rmsRollWithBLOBs.size() > 0) {
                                                rmsFileWithBLOBs.setRollId(rmsRollWithBLOBs.get(0).getRollId());
                                            } else {
                                                rmsFileWithBLOBs.setRollId(0);
                                            }
                                            break;
                                    }
                                }
                            }
                            if (rmsFileWithBLOBs.getRollId().equals(0)) {
                                rmsFileWithBLOBs.setImportStatus("导入失败，无该卷库");
                            } else {
                                rmsFileWithBLOBs.setAttachmentId("");
                                rmsFileWithBLOBs.setAttachmentName("");
                                try {
                                    rmsFileMapper.insertSelective(rmsFileWithBLOBs);
                                    rmsFileWithBLOBs.setImportStatus("导入成功");
                                } catch (Exception e) {
                                    rmsFileWithBLOBs.setImportStatus("导入失败，数据异常");
                                    e.printStackTrace();
                                }
                            }
                            // 添加进返回给前端的的集合里
                            list.add(rmsFileWithBLOBs);
                        }
                    }
                    json.setObj(list);
                }
            }
            json.setMsg("ok");
            json.setFlag(0);
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("err");
            json.setFlag(1);
        }
        finally {
            IOUtils.closeQuietly(in);
        }
        return json;
    }

    @Override
    public ToJson<RmsFileWithBLOBs> deleteFiles(String fileIds) {
        ToJson<RmsFileWithBLOBs> json = new ToJson<RmsFileWithBLOBs>();
        try {
            if (!StringUtils.checkNull(fileIds)) {
                rmsFileMapper.delete(fileIds.split(","));
            }
            json.setFlag(0);
            json.setMsg("ok");
        } catch (Exception e) {
            e.printStackTrace();
            json.setFlag(1);
            json.setMsg("err");
        }
        return json;
    }

    @Override
    public ToJson<RmsFileWithBLOBs> restore(String fileIds) {
        ToJson<RmsFileWithBLOBs> json = new ToJson<RmsFileWithBLOBs>();
        try {
            if (!StringUtils.checkNull(fileIds)) {
                rmsFileMapper.restore(fileIds.split(","));
                json.setFlag(0);
                json.setMsg("ok");
                return json;
            }

        } catch (Exception e) {
            e.printStackTrace();
            json.setFlag(1);
            json.setMsg("err");
        }
        json.setFlag(1);
        json.setMsg("err");
        return json;
    }

    @Override
    public ToJson<RmsFileWithBLOBs> export(String fileIds, HttpServletRequest request, HttpServletResponse response) {
        ToJson<RmsFileWithBLOBs> json = new ToJson<RmsFileWithBLOBs>();
        try (ServletOutputStream out = response.getOutputStream()){
            List<RmsFileWithBLOBs> list = rmsFileMapper.selectByFileIds(fileIds.split(","));

            HSSFWorkbook workbook1 = ExcelUtil.makeExcelHead("文件档案信息", 9);
            String[] secondTitles = {"文件号", "文件主题词", "文件标题", "文件辅标题", "发文单位", "发文日期", "密级", "紧急等级", "文件分类", "公文类别", "文件页数", "打印页数", "备注"};
            HSSFWorkbook workbook2 = ExcelUtil.makeSecondHead(workbook1, secondTitles);
            String[] beanProperty = {"fileCode", "fileSubject", "fileTitle", "fileTitle0", "sendUnit", "sendDate", "secretName", "urgencyName", "fileTypeName", "fileKindName", "filePage", "printPage", "remark"};

            HSSFWorkbook workbook = ExcelUtil.exportExcelData(workbook2, list, beanProperty);

            String filename = "文件档案.xls";
            filename = FileUtils.encodeDownloadFilename(filename, request.getHeader("user-agent"));
            response.setContentType("application/vnd.ms-excel");
            response.setHeader("content-disposition", "attachment;filename=" + filename);
            workbook.write(out);
        } catch (Exception e) {
            e.printStackTrace();
            json.setMsg("err");
            json.setFlag(1);
        }
        return json;
    }


    @Override
    public ToJson<RmsFileWithBLOBs> updateRollBath(String fileIds, Integer rollId) {
        ToJson<RmsFileWithBLOBs> json = new ToJson<RmsFileWithBLOBs>();
        try {
            if (!StringUtils.checkNull(fileIds)) {
                rmsFileMapper.updateRollBath(fileIds.split(","), rollId);
            }
            json.setFlag(0);
            json.setMsg("ok");
        } catch (Exception e) {
            e.printStackTrace();
            json.setFlag(1);
            json.setMsg("err");
        }
        return json;
    }

    @Override
    public ToJson<Attachment> createFormHtml(String content, String module, HttpServletResponse response, HttpServletRequest request, String typeFlag) {
        ToJson<Attachment> json = new ToJson<Attachment>();

            // 获取库
            Cookie redisSessionId = CookiesUtil.getCookieByName(request,"redisSessionId");
            String company = "xoa" + SessionUtils.getSessionInfo(request.getSession(), "loginDateSouse", String.class,redisSessionId);
            if(SessionUtils.getSessionInfo(request.getSession(), "loginDateSouse", String.class,redisSessionId)==null){
                company = "xoa1001";
            }

            if (StringUtils.checkNull(module)) {
                module = "roll_manage";
            }
            ResourceBundle rb =  ResourceBundle.getBundle("upload");
            String os = System.getProperty("os.name");
            StringBuffer sb=new StringBuffer();
            StringBuffer buffer=new StringBuffer();
		/*if(os.toLowerCase().startsWith("win")){
			sb=sb.append(rb.getString("upload.win"));
		}else{
			sb=sb.append(rb.getString("upload.linux"));
		}*/
            if(os.toLowerCase().startsWith("win")){
                //sb=sb.append(rb.getString("upload.win"));
                //判断路径是否是相对路径，如果是的话，加上运行的路径
                String uploadPath = rb.getString("upload.win");
                if(uploadPath.indexOf(":")==-1){
                    //获取运行时的路径
                    String basePath = this.getClass().getClassLoader().getResource(".").getPath()+File.pathSeparator;
                    //获取截取后的路径
                    String str2 = "";
                    if(basePath.indexOf("/xoa")!=-1){
                        //获取字符串的长度
                        int length = basePath.length();
                        //返回指定字符在此字符串中第一次出现处的索引
                        int index = basePath.indexOf("/xoa");
                        //从指定位置开始到指定位置结束截取字符串
                        str2=basePath.substring(0,index);
                    }
                    sb = sb.append(str2 + "/xoa");
                }
                sb.append(uploadPath);
                buffer=buffer.append(rb.getString("upload.win"));
            }else{
                sb=sb.append(rb.getString("upload.linux"));
                buffer=buffer.append(rb.getString("upload.linux"));
            }
            List<Attachment> list = new ArrayList<Attachment>();
            //当前年月
            String ym = new SimpleDateFormat("yyMM").format(new Date());
            //存储路径
            //HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            if(StringUtils.checkNull(sb.toString())){
                String a = request.getRealPath("");
                sb.append(a);
                sb.append(System.getProperty("file.separator")).
//                        append("attach").
//                        append(System.getProperty("file.separator")).
                        append(company).append(System.getProperty("file.separator")).
                        append("roll_manage").append(System.getProperty("file.separator")).append(ym);
            }else {
                sb.append(System.getProperty("file.separator")).
//                        append("attach").
//                        append(System.getProperty("file.separator")).
                        append(company).append(System.getProperty("file.separator")).
                        append("roll_manage").append(System.getProperty("file.separator")).append(ym);
            }
            String path = sb.toString();

            // 生成文件目录
            new File(path).mkdirs();

            // 获得原始文件名
            String fileName = "工作流表单.html";

            String attachID =String.valueOf(Math.abs((int) System.currentTimeMillis())) ;
            String newFileName = attachID + "." + fileName.toString();

            // 生成文件
            String filePath = path + System.getProperty("file.separator") + newFileName;
            File f = new File(filePath);
        try (FileOutputStream fileOutputStream = new FileOutputStream(filePath);OutputStreamWriter pw = new OutputStreamWriter(fileOutputStream, "UTF-8")){
            if (!f.exists()) {
                f.createNewFile();
            }
            pw.write("<html><head><meta charset=\"UTF-8\"><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\"></head>");
            pw.write(HTML_STYLE);
            pw.write("<body>");
            pw.write(content);
            pw.write("</body></html>");

            //获得模块名
            int moduleID = 0;
            for (ModuleEnum em : ModuleEnum.values()) {
                if (em.getName().equals(module.trim())) {
                    moduleID = em.getIndex();
                }
            }

            byte mid = (byte) moduleID;

            if ("1".equals(typeFlag)) {
                // 保存进数据库
                Attachment attachment = new Attachment();
                attachment = new Attachment();
                attachment.setAttachId(attachID);
                attachment.setModule(mid);
                attachment.setAttachFile(fileName);
                attachment.setAttachName(fileName);
                attachment.setYm(ym);
                attachment.setAttachSign(new Long(0));
                attachment.setDelFlag((byte) 0);
                attachment.setPosition((byte) 2);
                attachment.setIsImage((byte) 0);
                attachment.setFileSize(String.valueOf(f.length()));
                attachment.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));

                attachmentMapper.insertSelective(attachment);
                json.setObject(attachment);
            } else if ("2".equals(typeFlag)) {

                String zipPath = filePath.replace("工作流表单.html", "工作流表单.zip");

                ZipUtils.zip(filePath, zipPath);
                // 获取zipFile
                File zipFile = new File(zipPath);
                // 如果文件不存在
                if (!zipFile.exists()) {
                    json.setFlag(1);
                    json.setMsg("zip文件不存在");
                    return json;
                }

                fileName = "工作流表单.zip";
                // 保存进数据库
                Attachment attachment = new Attachment();
                attachment = new Attachment();
                attachment.setAttachId(attachID);
                attachment.setModule(mid);
                attachment.setAttachFile(fileName);
                attachment.setAttachName(fileName);
                attachment.setYm(ym);
                attachment.setAttachSign(new Long(0));
                attachment.setDelFlag((byte) 0);
                attachment.setPosition((byte) 2);
                attachment.setIsImage((byte) 0);
                attachment.setSize(String.valueOf(f.length()));
                attachment.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));

                attachmentMapper.insertSelective(attachment);
                json.setObject(attachment);

                String attUrl = "AID=" + attachment.getAid() + "&" + "MODULE=" + module + "&" + "COMPANY=" + company + "&" + "YM=" + attachment.getYm() + "&" + "ATTACHMENT_ID=" + attachment.getAttachId() + "&" +
                        "ATTACHMENT_NAME=" + attachment.getAttachName() + "&" + "FILESIZE=" + attachment.getFileSize();

                attachment.setAttUrl(attUrl);


                /*response.setContentType("application/x-zip-compressed");
                response.setHeader("content-disposition", "attachment;filename=" + "form.zip");

                InputStream inputStream = new FileInputStream(zipFile);
                OutputStream outputStream = response.getOutputStream();
                byte[] b = new byte[2048];
                int length;
                while ((length = inputStream.read(b)) > 0) {
                    outputStream.write(b, 0, length);
                }
                // 这里主要关闭
                outputStream.close();
                inputStream.close();
                // 删除文件
                f.delete();
                zipFile.delete();*/
            }
            json.setFlag(0);
            json.setMsg("ok");
        } catch (Exception e) {
            e.printStackTrace();
            json.setFlag(1);
            json.setMsg("err");
        }
        return json;
    }

    /**
     * @作者: 张航宁
     * @时间: 2019/8/8
     * @说明: 获取流程中的来文单位 文号 文件标题 案卷数据
     */
    @Override
    public ToJson<RmsFileWithBLOBs> getFlowData(Integer runId) {

        ToJson<RmsFileWithBLOBs> json = new ToJson<RmsFileWithBLOBs>();

        // 初始化返回对象
        RmsFileWithBLOBs rmsFileWithBLOBs = new RmsFileWithBLOBs();
        rmsFileWithBLOBs.setFileTitle("");
        rmsFileWithBLOBs.setSendUnit("");
        rmsFileWithBLOBs.setFileCode("");

        FlowRun flowRun = flowRunMapper.selectByRunId(runId);

        // 根据流程名设置案卷
        String flowName = flowTypeModelMapper.getFlowName(flowRun.getFlowId());

        if(!StringUtils.checkNull(flowName)){
            List<RmsRollWithBLOBs> rmsRollWithBLOBs = rmsRollMapper.selectByName(flowName);
            if(rmsRollWithBLOBs!=null&&rmsRollWithBLOBs.size()>0){
                rmsFileWithBLOBs.setRollId(rmsRollWithBLOBs.get(0).getRollId());
            }
        }

        // 获取无数据的表单信息
        FlowFormType flowFormType = null;
        List<FlowFormType> frombyFlowId = wfeFormTypeMapper.getFrombyFlowId(flowRun.getFlowId());
        if (frombyFlowId != null && frombyFlowId.size() > 0) {
            flowFormType = frombyFlowId.get(0);
        }

        // 数据查询参数map
        Map<String,Object> parameterMap = new HashMap<String,Object>();
        parameterMap.put("tableName", "flow_data_" + flowRun.getFlowId());
        parameterMap.put("runId", runId);
        // 查询表单数据
        Map<String,Object> dataMap = workMapper.select(parameterMap);

        String htmlContent = flowFormType.getPrintModel();
        // 通过Jsoup插件解析成document对象（非公文的document对象）
        Document parse = Jsoup.parse(htmlContent);

        if(dataMap==null)
            return json;

        Iterator<Map.Entry<String, Object>> iterator = dataMap.entrySet().iterator();

        // 循环获取到key和value
        while (iterator.hasNext()){
            Map.Entry<String, Object> entry = iterator.next();
            Element element = parse.getElementById(String.valueOf(entry.getKey()).toUpperCase());
            // 赋值操作
            if (element != null) {

                String title = element.attr("title");

                String value = String.valueOf(entry.getValue());

                if(title.equals("文件名称")){
                    rmsFileWithBLOBs.setFileTitle(value);
                } else if(title.equals("来文机关")){
                    rmsFileWithBLOBs.setSendUnit(value);
                } else if(title.equals("原文号")){
                    rmsFileWithBLOBs.setFileCode(value);
                }

            }
        }

        json.setFlag(0);
        json.setObject(rmsFileWithBLOBs);
        return json;
    }

    /**
    * @创建作者:李然  Lr
    * @方法描述：获得权限并返回数据
    * @创建时间：10:44 2018/9/6

    **/
    @Override
    public ToJson viewDetails(Users user, Integer runId) {
        ToJson<FlowRun> toJson=new ToJson();
        Integer flowId=null;
        if(runId!=null){
            flowId=attachmentMapper.viewDetailsByRunId(runId,user.getUserId());
        }
        if(flowId==null){
            flowId=attachmentMapper.viewDetailsByUser(user,runId);
        }
        if(flowId!=null){
            FlowRun flowRun=new FlowRun();
            flowRun.setRunId(runId);
            flowRun.setFlowId(flowId);
            toJson.setObject(flowRun);
            toJson.setMsg("ok");
            toJson.setFlag(0);
            return toJson;
        }
        toJson.setFlag(1);
        toJson.setMsg("no");
        return toJson;
    }

    public final String HTML_STYLE =
            "<style id=\"css_index\" index=\"index\" type=\"text/css\">" +
                    "@charset \"utf-8\";\n" +
                    "\n" +
                    "body,\n" +
                    "h1,\n" +
                    "h2,\n" +
                    "h3,\n" +
                    "h4,\n" +
                    "h5,\n" +
                    "h6,\n" +
                    "hr,\n" +
                    "p,\n" +
                    "blockquote,\n" +
                    "dl,\n" +
                    "dt,\n" +
                    "dd,\n" +
                    "ul,\n" +
                    "ol,\n" +
                    "li,\n" +
                    "pre,\n" +
                    "form,\n" +
                    "fieldset,\n" +
                    "legend,\n" +
                    "button,\n" +
                    "input,\n" +
                    "textarea,\n" +
                    "th,\n" +
                    "td {\n" +
                    "    margin:0;\n" +
                    "    padding:0;\n" +
                    "}\n" +
                    "\n" +
                    "body,\n" +
                    "button,\n" +
                    "input,\n" +
                    "select,\n" +
                    "textarea {\n" +
                    "    font:12px/1.5 \"\\5FAE\\8F6F\\96C5\\9ED1\", arial ;\n" +
                    "    *line-height:1.5;\n" +
                    "}\n" +
                    "\n" +
                    "h1,\n" +
                    "h2,\n" +
                    "h3,\n" +
                    "h4,\n" +
                    "h5,\n" +
                    "h6 {\n" +
                    "    font-size:100%;\n" +
                    "    font-weight: normal;\n" +
                    "}\n" +
                    "\n" +
                    "address,\n" +
                    "cite,\n" +
                    "dfn,\n" +
                    "em,\n" +
                    "var {\n" +
                    "    font-style:normal;\n" +
                    "}\n" +
                    "\n" +
                    "code,\n" +
                    "kbd,\n" +
                    "pre,\n" +
                    "samp {\n" +
                    "    font-family:courier new, courier, monospace;\n" +
                    "}\n" +
                    "\n" +
                    "ul,\n" +
                    "ol {\n" +
                    "    list-style:none;\n" +
                    "}\n" +
                    "\n" +
                    "fieldset,\n" +
                    "img {\n" +
                    "    border:0;\n" +
                    "}\n" +
                    "\n" +
                    "table {\n" +
                    "    border-collapse:collapse;\n" +
                    "    border-spacing:0;\n" +
                    "}\n" +
                    "\n" +
                    "input,\n" +
                    "button,\n" +
                    "textarea,\n" +
                    "select,\n" +
                    "optgroup,\n" +
                    "option {\n" +
                    "    font-family: inherit;\n" +
                    "    font-size: inherit;\n" +
                    "    font-style: inherit;\n" +
                    "    font-weight: inherit;\n" +
                    "    font-size:100%;\n" +
                    "}\n" +
                    "\n" +
                    "div:after,\n" +
                    "ul:after,\n" +
                    "dl:after,\n" +
                    ".clearfix:after {\n" +
                    "    content:\"\";\n" +
                    "    display:block;\n" +
                    "    clear:both;\n" +
                    "    height:0;\n" +
                    "    visibility:hidden;\n" +
                    "}\n" +
                    "\n" +
                    "/****/\n" +
                    "abbr,\n" +
                    "article,\n" +
                    "aside,\n" +
                    "audio,\n" +
                    "canvas,\n" +
                    "datalist,\n" +
                    "details,\n" +
                    "figure,\n" +
                    "footer,\n" +
                    "header,\n" +
                    "hgroup,\n" +
                    "menu,\n" +
                    "nav,\n" +
                    "output,\n" +
                    "progress,\n" +
                    "section,\n" +
                    "video {\n" +
                    "    display:block;\n" +
                    "    margin:0;\n" +
                    "    padding:0;\n" +
                    "}\n" +
                    "\n" +
                    "i,\n" +
                    "u,\n" +
                    "b,\n" +
                    "em,\n" +
                    "span,\n" +
                    "small{\n" +
                    "    font-weight:normal;\n" +
                    "    font-style:normal;\n" +
                    "}\n" +
                    "\n" +
                    "html,\n" +
                    "body {\n" +
                    "    height: 100%;\n" +
                    "}\n" +
                    "\n" +
                    "/****/\n" +
                    "html {\n" +
                    "    font-size: 62.5%;\n" +
                    "}\n" +
                    "\n" +
                    "body {\n" +
                    "    -webkit-tap-highlight-color: rgba(255, 255, 255, 0);\n" +
                    "    -webkit-user-select: none;\n" +
                    "    user-select: none;\n" +
                    "    -moz-user-focus: none;\n" +
                    "    -moz-user-select: none;\n" +
                    "}\n" +
                    "\n" +
                    "a{\n" +
                    "    text-decoration: none;\n" +
                    "}\n" +
                    "\n" +
                    "h2{\n" +
                    "    margin:0;\n" +
                    "    padding: 0;\n" +
                    "}\n" +
                    "\n" +
                    "ul{\n" +
                    "    word-spacing: -4px;\n" +
                    "}\n" +
                    "\n" +
                    ".body{\n" +
                    "    width:100%;\n" +
                    "//height:100%;\n" +
                    "//overflow: hidden;\n" +
                    "}\n" +
                    ".head{\n" +
                    "    width:100%;\n" +
                    "    height:45px;\n" +
                    "    border-bottom:1px solid #999;\n" +
                    "    background-color:#f8f8f8;\n" +
                    "    overflow:hidden;\n" +
                    "}\n" +
                    ".abs_left,.abs_right{\n" +
                    "    height:100%;\n" +
                    "    float:left;\n" +
                    "\n" +
                    "}\n" +
                    ".abs_right{\n" +
                    "    width:auto;\n" +
                    "    position: absolute;\n" +
                    "    right: 24px;\n" +
                    "}\n" +
                    ".abs_left{\n" +
                    "    width: auto;\n" +
                    "}\n" +
                    ".num,.step{\n" +
                    "    float:left;\n" +
                    "}\n" +
                    ".num{\n" +
                    "    font-size: 12pt;\n" +
                    "    font-weight: bold;\n" +
                    "    margin-left: 17px;\n" +
                    "    line-height: 45px;\n" +
                    "}\n" +
                    ".step{\n" +
                    "    color: #4b4b4b;\n" +
                    "    line-height: 45px;\n" +
                    "    margin-left: 13px;\n" +
                    "    font-size: 10pt;\n" +
                    "}\n" +
                    ".opt{\n" +
                    "    margin-top: 10px !important;\n" +
                    "    margin-left: 17px !important;\n" +
                    "    color: #205f82;\n" +
                    "    width: 62px;\n" +
                    "    height: 28px;\n" +
                    "    border-radius: 3px;\n" +
                    "    background: #f6f6f6;\n" +
                    "}\n" +
                    ".abs_right ul {\n" +
                    "    width: 275px;\n" +
                    "    height: 28px;\n" +
                    "    border: 1px solid #4889f0;\n" +
                    "    border-radius: 5px;\n" +
                    "    margin:7px auto;\n" +
                    "}\n" +
                    ".check{\n" +
                    "    background: #4889f0 ;\n" +
                    "    color:#fff ;\n" +
                    "}\n" +
                    ".abs_right{\n" +
                    "    color:#4889f0;\n" +
                    "}\n" +
                    "#tab_t ul li{\n" +
                    "    float:left;\n" +
                    "    width: 68px;\n" +
                    "    height:100%;\n" +
                    "    border-right:1px solid #4889f0;\n" +
                    "    text-align: center;\n" +
                    "    line-height: 28px;\n" +
                    "}\n" +
                    ".abs_right ul li:nth-child(4){\n" +
                    "    border:none !important;\n" +
                    "}\n" +
                    "\n" +
                    ".cont{\n" +
                    "}\n" +
                    ".cont_form{\n" +
                    "    width: 100%;\n" +
                    "//background: #e6ebef;\n" +
                    "    height: 99%;\n" +
                    "    margin: auto;\n" +
                    "    overflow-x: hidden;\n" +
                    "    overflow-y: scroll;\n" +
                    "}\n" +
                    ".foot{\n" +
                    "    width:100%;\n" +
                    "    height:52px;\n" +
                    "    background-color: #eaeaea;\n" +
                    "    position: fixed;\n" +
                    "    bottom: 0px;\n" +
                    "    z-index: 9999;\n" +
                    "}\n" +
                    ".foot_left,.foot_rig{\n" +
                    "    height:100%;\n" +
                    "}\n" +
                    ".foot_left{\n" +
                    "    float:left;\n" +
                    "    margin-left: 36px;\n" +
                    "    width:310px;\n" +
                    "}\n" +
                    ".foot_rig{\n" +
                    "    float:right;\n" +
                    "    width:685px;\n" +
                    "    margin-right: 24px;\n" +
                    "}\n" +
                    ".foot_left ul,.foot_rig ul{\n" +
                    "    margin-top:11px;\n" +
                    "}\n" +
                    ".foot_left ul li,.foot_rig ul li{\n" +
                    "    float:left;\n" +
                    "    width: 70px;\n" +
                    "    height:28px;\n" +
                    "    /*border:1px solid #4889f0;*/\n" +
                    "    text-align: center;\n" +
                    "    line-height: 28px;\n" +
                    "    color:#4889f0;\n" +
                    "    border-radius: 5px;\n" +
                    "}\n" +
                    "\n" +
                    ".rig_h1onexiayibu{\n" +
                    "    background:url(\"/img/workflow/work/zhuanjiao.png\") no-repeat ;\n" +
                    "    color: #fff!important;\n" +
                    "    width: 80px!important;\n" +
                    "}\n" +
                    ".saveformlo{\n" +
                    "    background:url(\"/img/workflow/work/huitui.png\") no-repeat ;\n" +
                    "    /*color: #fff!important;*/\n" +
                    "    width: 73px!important;\n" +
                    "}\n" +
                    ".baocunfanhui{\n" +
                    "    background:url(\"/img/workflow/work/baocunfanhui.png\") no-repeat ;\n" +
                    "    /*color: #fff!important;*/\n" +
                    "    width: 76px!important;\n" +
                    "}\n" +
                    ".foot_left ul li,.foot_rig ul li.active{\n" +
                    "//color:#fff;\n" +
                    "}\n" +
                    ".foot_left ul li{\n" +
                    "    margin-left: 3%;\n" +
                    "}\n" +
                    ".foot_rig ul li{\n" +
                    "    float: right;\n" +
                    "    margin-left: 2%;\n" +
                    "}\n" +
                    ".foot_rig ul li:nth-child(1){\n" +
                    "    width: 90px !important;\n" +
                    "}\n" +
                    ".foot_rig ul li:nth-child(3){\n" +
                    "    width: 90px !important;\n" +
                    "}\n" +
                    ".backbtn{\n" +
                    "    cursor: pointer;\n" +
                    "}\n" +
                    ".left_img,.left_h1,.rig_img,.rig_h1{\n" +
                    "    float:left;\n" +
                    "}\n" +
                    ".left_img,.rig_img{\n" +
                    "    margin-left: 5px;\n" +
                    "    margin-top: 4px;\n" +
                    "    margin-right: 3px;\n" +
                    "}\n" +
                    ".left_h1{\n" +
                    "    margin-left: 1px;\n" +
                    "}\n" +
                    "/*select{\n" +
                    "\tmargin-top: 10px !important;\n" +
                    "}*/\n" +
                    "/*注意*/\n" +
                    ".rig_h1{\n" +
                    "    width: 100%;\n" +
                    "    text-align: center;\n" +
                    "}\n" +
                    "#tab_t ul li,.foot ul li{\n" +
                    "    cursor: pointer;\n" +
                    "}\n" +
                    "/*定义滚动条宽高及背景，宽高分别对应横竖滚动条的尺寸*/\n" +
                    ".cont_form::-webkit-scrollbar{\n" +
                    "    width: 0px;\n" +
                    "    height: 16px;\n" +
                    "    background-color: #f5f5f5;\n" +
                    "}\n" +
                    "/*定义滚动条的轨道，内阴影及圆角*/\n" +
                    ".cont_form::-webkit-scrollbar-track{\n" +
                    "    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);\n" +
                    "    border-radius: 10px;\n" +
                    "    background-color: #f5f5f5;\n" +
                    "}\n" +
                    "/*定义滑块，内阴影及圆角*/\n" +
                    ".cont_form::-webkit-scrollbar-thumb{\n" +
                    "    /*width: 10px;*/\n" +
                    "    height: 20px;\n" +
                    "    border-radius: 10px;\n" +
                    "    -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);\n" +
                    "    background-color: #555;\n" +
                    "}\n" +
                    "\n" +
                    "body, button, select, textarea, input, label, option, fieldset, legend{font-family: 微软雅黑E\\8F6F\\96C5\\9ED1,Tahoma,Verdana;font-size: 12px;line-height: 18px;color: #444;}\n" +
                    "body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, form, fieldset, legend, textarea, button, p, blockquote{margin: 0;padding: 0;}\n" +
                    "textarea{resize: none}\n" +
                    "a,img{border:0;}\n" +
                    "a{color: #666;text-decoration: none;}\n" +
                    "li{list-style-type:none;}\n" +
                    ".fl{float:left;}\n" +
                    ".fr{float:right;}\n" +
                    ".nf{clear:both;}\n" +
                    ".red{color:red;font-weight:bold;}\n" +
                    ".green{color:#00b500;font-weight:bold;}\n" +
                    ".ds{display:block;}\n" +
                    ".hid{overflow:hidden;}\n" +
                    ".clearfix{*zoom:1}\n" +
                    ".clearfix:after{display:block;visibility:hidden;clear:both;height:0;content:'.';font-size:0}\n" +
                    ".jianbian{background: -webkit-gradient(linear,left top,left bottom,color-stop(0%,#f4f4f4),color-stop(100%,#eee));background: -webkit-linear-gradient(top,#f4f4f4 0,#eee 100%);background: linear-gradient(to bottom,#f4f4f4 0,#eee 100%);}\n" +
                    ".bottomshadow{border-bottom: solid 1px #B3B3B3;-webkit-box-shadow: 0 1px 1px 0 #DFDFDF;box-shadow: 0 1px 1px 0 #DFDFDF;}\n" +
                    ".TableBlock{\n" +
                    "    border: 1px solid #dddddd;\n" +
                    "    line-height: 20px;\n" +
                    "    font-size: 9pt;\n" +
                    "    border-collapse: collapse;\n" +
                    "}\n" +
                    "table{\n" +
                    "    border-collapse: collapse;\n" +
                    "    border-spacing: 0;\n" +
                    "}\n" +
                    ".TableBlock .TableContent td, .TableBlock td.TableContent{\n" +
                    "    background: #f2f2f2;\n" +
                    "    border: 1px #dddddd solid;\n" +
                    "    border-right: 1px #dddddd solid;\n" +
                    "    padding: 3px;\n" +
                    "    height: 37px;\n" +
                    "}\n" +
                    "input.BigInput{\n" +
                    "    height: 20px;\n" +
                    "}\n" +
                    "input,select,textarea{\n" +
                    "    outline:none;\n" +
                    "    border: none;\n" +
                    "}\n" +
                    "input.BigStatic, textarea.BigStatic {\n" +
                    "    font-size: 9pt;\n" +
                    "    padding: 1px 5px;\n" +
                    "    border: 1px solid #C0BBB4;\n" +
                    "    background: #E0E0E0;\n" +
                    "}\n" +
                    "textarea {\n" +
                    "    overflow: auto;\n" +
                    "    /* vertical-align: top; */\n" +
                    "    white-space: pre-wrap;\n" +
                    "}\n" +
                    ".MessageBox .msg .center {\n" +
                    "    padding-left: 90px;\n" +
                    "    font-size: 16px;\n" +
                    "    background-color: #357ece;\n" +
                    "}\n" +
                    ".MessageBox .msg td {\n" +
                    "    height: 90px;\n" +
                    "}\n" +
                    ".MessageBox .head-no-title td {\n" +
                    "    height: 16px;\n" +
                    "}\n" +
                    ".bodycolor{\n" +
                    "    BACKGROUND: #f6f7f9;\n" +
                    "    padding-top: 5px;\n" +
                    "}\n" +
                    "input.BigInput, textarea.BigInput{\n" +
                    "    font-size: 10pt;\n" +
                    "    padding: 1px 5px;\n" +
                    "    line-height: 20px;\n" +
                    "    border: 1px solid #C0BBB4;\n" +
                    "    background: white url(/img/app/bg_input_text_hover.png) top left repeat-x;\n" +
                    "    background-position: 0 -1px;\n" +
                    "}\n" +
                    ".TableBlock .TableFooter td, .TableBlock .TableControl td, .TableBlock td.TableFooter, .TableBlock td.TableControl{\n" +
                    "    background: #FFFFFF;\n" +
                    "    border: 1px #dddddd solid;\n" +
                    "    /*padding: 3px;*/\n" +
                    "    height: 37px;\n" +
                    "}\n" +
                    "input.BigButton{\n" +
                    "    background-color: #fafafa;\n" +
                    "    background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #fafafa), color-stop(100%, #f1f1f1));\n" +
                    "    background: -webkit-linear-gradient(top, #fafafa, #f1f1f1);\n" +
                    "    background: -moz-linear-gradient(top, #fafafa, #f1f1f1);\n" +
                    "    background: -o-linear-gradient(top, #fafafa, #f1f1f1);\n" +
                    "    background: linear-gradient(top, #fafafa, #f1f1f1);\n" +
                    "    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffafafa',endColorstr='#fff1f1f1',GradientType=0);\n" +
                    "    filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);\n" +
                    "    border: 1px solid #ddd;\n" +
                    "    -webkit-border-radius: 3px;\n" +
                    "    -moz-border-radius: 3px;\n" +
                    "    -ms-border-radius: 3px;\n" +
                    "    -o-border-radius: 3px;\n" +
                    "    border-radius: 3px;\n" +
                    "    height: 24px;\n" +
                    "    line-height: 14px;\n" +
                    "    padding: 4px 10px;\n" +
                    "    font-size: 14px;\n" +
                    "    color: #333;\n" +
                    "    margin: 1px;\n" +
                    "    text-decoration: none;\n" +
                    "    text-align: center;\n" +
                    "    cursor: pointer;\n" +
                    "    -webkit-appearance: none;\n" +
                    "}\n" +
                    "a.BigButton{\n" +
                    "    background-color: #fafafa;\n" +
                    "    background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #fafafa), color-stop(100%, #f1f1f1));\n" +
                    "    background: -webkit-linear-gradient(top, #fafafa, #f1f1f1);\n" +
                    "    background: -moz-linear-gradient(top, #fafafa, #f1f1f1);\n" +
                    "    background: -o-linear-gradient(top, #fafafa, #f1f1f1);\n" +
                    "    background: linear-gradient(top, #fafafa, #f1f1f1);\n" +
                    "    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#fffafafa',endColorstr='#fff1f1f1',GradientType=0);\n" +
                    "    filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);\n" +
                    "    border: 1px solid #ddd;\n" +
                    "    -webkit-border-radius: 3px;\n" +
                    "    -moz-border-radius: 3px;\n" +
                    "    -ms-border-radius: 3px;\n" +
                    "    -o-border-radius: 3px;\n" +
                    "    border-radius: 3px;\n" +
                    "    height: 24px;\n" +
                    "    line-height: 14px;\n" +
                    "    padding: 4px 10px;\n" +
                    "    font-size: 12px;\n" +
                    "    color: #111!important;\n" +
                    "    color: #333;\n" +
                    "    margin: 1px;\n" +
                    "    text-decoration: none;\n" +
                    "    text-align: center;\n" +
                    "    cursor: pointer;\n" +
                    "    -webkit-appearance: none;\n" +
                    "}\n" +
                    "input.BigButton:hover{\n" +
                    "    background: #fafafa;\n" +
                    "    box-shadow: 0px -12px 5px 0px #C8F1FE inset;\n" +
                    "}\n" +
                    "a.BigButton:hover{\n" +
                    "    background: #fafafa;\n" +
                    "    box-shadow: 0px -12px 5px 0px #C8F1FE inset;\n" +
                    "}\n" +
                    "body {\n" +
                    "\n" +
                    "    line-height: 1;\n" +
                    "}\n" +
                    "#navMenu a.active span, #navMenu a:hover span{\n" +
                    "    height: 28px;\n" +
                    "    background: url(/img/app/menu_top_hover_r.png) no-repeat top right;\n" +
                    "}\n" +
                    "#navPanel {\n" +
                    "    width: 100%;\n" +
                    "    height: 30px;\n" +
                    "    padding-top: 2px;\n" +
                    "    font-size: 10pt;\n" +
                    "    background: #D6E4EF url(/img/app/menu_top_bg.png) left -30px repeat-x;\n" +
                    "}\n" +
                    "#navMenu {\n" +
                    "    float: left;\n" +
                    "    white-space: nowrap;\n" +
                    "    padding: 0px 20px;\n" +
                    "    height: 30px;\n" +
                    "    overflow: hidden;\n" +
                    "}\n" +
                    "#navMenu a.active, #navMenu a:hover {\n" +
                    "    color: #FFFFFF;\n" +
                    "    font-weight: bold;\n" +
                    "    background: url(/img/app/menu_top_hover_l.png) no-repeat top left;\n" +
                    "}\n" +
                    "#navMenu a {\n" +
                    "    float: left;\n" +
                    "    overflow: hidden;\n" +
                    "    color: #000000;\n" +
                    "    text-decoration: none;\n" +
                    "    padding-left: 5px;\n" +
                    "    background: url(/img/app/menu_top_line.png) no-repeat top right;\n" +
                    "    height: 30px;\n" +
                    "}\n" +
                    "#navMenu a span {\n" +
                    "    float: left;\n" +
                    "    cursor: pointer;\n" +
                    "    padding: 6px 5px 6px 5px;\n" +
                    "}\n" +
                    ".mainLeft{\n" +
                    "    width: 19%;\n" +
                    "    float: left;\n" +
                    "    height: 100%;\n" +
                    "}\n" +
                    ".mainRight{\n" +
                    "    width: 100%;\n" +
                    "    float: left;\n" +
                    "}\n" +
                    ".TableList {\n" +
                    "    border: 1px #dddddd solid;\n" +
                    "    line-height: 21px;\n" +
                    "    font-size: 9pt;\n" +
                    "    border-collapse: collapse;\n" +
                    "    padding: 3px;\n" +
                    "    margin-top: 8px;\n" +
                    "}\n" +
                    ".TableHeader {\n" +
                    "    COLOR: #383838;\n" +
                    "    FONT-WEIGHT: bold;\n" +
                    "    FONT-SIZE: 9pt;\n" +
                    "    background: #fff;\n" +
                    "    line-height: 40px;\n" +
                    "    border-bottom: 1px #c0c0c0 solid;\n" +
                    "}\n" +
                    ".TableList .TableHeader td, .TableList td.TableHeader {\n" +
                    "    height: 30px;\n" +
                    "    background: #ffffff;\n" +
                    "    font-weight: bold;\n" +
                    "    text-align: center;\n" +
                    "    color: #383838;\n" +
                    "    padding: 0px;\n" +
                    "}\n" +
                    ".fileload{\n" +
                    "    position: absolute;\n" +
                    "    filter:alpha(opacity=0);\n" +
                    "    -moz-opacity:0;\n" +
                    "    -khtml-opacity: 0;\n" +
                    "    opacity: 0;\n" +
                    "    width: 84px;\n" +
                    "    right: 108px;\n" +
                    "    height: 30px;\n" +
                    "}\n" +
                    ".TableLine1 {\n" +
                    "    BACKGROUND: #F3F3F3;\n" +
                    "}\n" +
                    ".TableLine2 {\n" +
                    "    BACKGROUND: #FFFFFF;\n" +
                    "}\n" +
                    ".TableList .TableLine1 td, .TableList td.TableLine1 {\n" +
                    "\n" +
                    "    border-bottom: 1px #dddddd solid;\n" +
                    "    border-bottom-width: 1px;\n" +
                    "    border-bottom-style: solid;\n" +
                    "    border-bottom-color: rgb(221, 221, 221);\n" +
                    "    padding: 3px;\n" +
                    "    height: 30px;\n" +
                    "    text-align: center;\n" +
                    "}\n" +
                    ".TableList .TableLine2 td, .TableList td.TableLine2 {\n" +
                    "    background: #FFFFFF;\n" +
                    "    border-bottom: 1px #dddddd solid;\n" +
                    "    padding: 3px;\n" +
                    "    height: 30px;\n" +
                    "    text-align: center;\n" +
                    "}\n" +
                    "a:visited {\n" +
                    "    color: #1687cb;\n" +
                    "    text-decoration: none;\n" +
                    "}\n" +
                    "a:link {\n" +
                    "    color: #1687cb;\n" +
                    "    text-decoration: none;\n" +
                    "}\n" +
                    ".big3 {\n" +
                    "    font-size: 12pt;\n" +
                    "    COLOR: #124164;\n" +
                    "    FONT-WEIGHT: bold;\n" +
                    "}\n" +
                    ".MessageBox {\n" +
                    "    margin: 0px auto;\n" +
                    "}\n" +
                    ".MessageBox .head .left {\n" +
                    "    width: 20px;\n" +
                    "    background: url(/img/app/message_bg.png) left 0px no-repeat;\n" +
                    "}\n" +
                    ".MessageBox .head .right {\n" +
                    "    width: 20px;\n" +
                    "    background: url(/img/app/message_bg.png) right 0px no-repeat;\n" +
                    "}\n" +
                    ".MessageBox .head .center {\n" +
                    "    padding: 0px;\n" +
                    "    background: url(/img/app/message_bg.png) 0px -32px repeat-x;\n" +
                    "}\n" +
                    ".MessageBox .head .center .title {\n" +
                    "    float: left;\n" +
                    "    color: #fff;\n" +
                    "    font-size: 16px;\n" +
                    "    font-weight: bold;\n" +
                    "}\n" +
                    ".MessageBox .head td {\n" +
                    "    height: 32px;\n" +
                    "    overflow: hidden;\n" +
                    "}\n" +
                    ".MessageBox .msg .left {\n" +
                    "    width: 20px;\n" +
                    "    background: url(/img/app/message_center_bg.png) left top repeat-y;\n" +
                    "}\n" +
                    ".MessageBox .msg .info {\n" +
                    "    background-image: url(/img/app/icon64_info.png);\n" +
                    "    background-position: 0px 10px;\n" +
                    "    background-repeat: no-repeat;\n" +
                    "}\n" +
                    ".MessageBox .msg .center .msg-content {\n" +
                    "    color: #fff;\n" +
                    "    margin: 20px 12px 20px 6px;\n" +
                    "}\n" +
                    ".MessageBox .msg .right {\n" +
                    "    width: 20px;\n" +
                    "    background: url(/img/app/message_center_bg.png) right top repeat-y;\n" +
                    "}\n" +
                    ".MessageBox .foot .left {\n" +
                    "    width: 20px;\n" +
                    "    background: url(/img/app/message_bg.png) left -64px no-repeat;\n" +
                    "}\n" +
                    ".MessageBox .foot .center {\n" +
                    "    background: url(/img/app/message_bg.png) 0px -80px repeat-x;\n" +
                    "    position: relative;\n" +
                    "}\n" +
                    ".MessageBox .foot .right {\n" +
                    "    width: 20px;\n" +
                    "    background: url(/img/app/message_bg.png) right -64px no-repeat;\n" +
                    "}\n" +
                    ".MessageBox .foot td {\n" +
                    "    height: 16px;\n" +
                    "}\n" +
                    ".MessageBox .msg .center {\n" +
                    "    padding-left: 90px;\n" +
                    "    font-size: 16px;\n" +
                    "    background-color: #357ece;\n" +
                    "}\n" +
                    ".TableBlock .TableData td, .TableBlock td.TableData {\n" +
                    "    background: #FFFFFF;\n" +
                    "    border-bottom: 1px #dddddd solid;\n" +
                    "    border-top: 1px #dddddd solid;\n" +
                    "    border-right: 1px #dddddd solid;\n" +
                    "    padding: 3px;\n" +
                    "    height: 37px;\n" +
                    "}\n" +
                    ".MessageBox .head-no-title .left {\n" +
                    "    width: 20px;\n" +
                    "    background: url(/img/app/message_bg.png) left -96px no-repeat;\n" +
                    "}\n" +
                    ".MessageBox .head-no-title .center {\n" +
                    "    background: url(/img/app/message_bg.png) 0px -112px repeat-x;\n" +
                    "}\n" +
                    ".MessageBox .head-no-title .right {\n" +
                    "    width: 20px;\n" +
                    "    background: url(/img/app/message_bg.png) right -96px no-repeat;\n" +
                    "}\n" +
                    ".w {\n" +
                    "    width: 100%;\n" +
                    "    margin: 0 auto;\n" +
                    "}\n" +
                    ".head {\n" +
                    "    border-bottom: 1px solid #9E9E9E;\n" +
                    "    padding-bottom: 3px;\n" +
                    "    height: 43px;\n" +
                    "}\n" +
                    ".head li {\n" +
                    "    /*width: 120px;*/\n" +
                    "    /* text-align: center; */\n" +
                    "    height: 28px;\n" +
                    "    line-height: 28px;\n" +
                    "    display: inline-block;\n" +
                    "    float: left;\n" +
                    "    font-family: \"微软雅黑\";\n" +
                    "    font-size: 14px;\n" +
                    "    margin-left: 20px;\n" +
                    "    margin-top: 6px;\n" +
                    "    cursor: pointer;\n" +
                    "}\n" +
                    ".head .headli1_1 {\n" +
                    "    /*width: 90px;*/\n" +
                    "    padding:0 14px;\n" +
                    "    display: inline-block;\n" +
                    "    text-align: center;\n" +
                    "}\n" +
                    ".head .headli1_2 {\n" +
                    "    width: 2px;\n" +
                    "    width: 2px;\n" +
                    "    /* margin: 0 10px; */\n" +
                    "    margin-left: 26px;\n" +
                    "}\n" +
                    "img {\n" +
                    "    border: 0;\n" +
                    "    vertical-align: middle;\n" +
                    "}\n" +
                    ".head .one {\n" +
                    "    background-color: #2F8AE3;\n" +
                    "    font-size: 14px;\n" +
                    "    color: #ffffff;\n" +
                    "    border-radius: 20px;\n" +
                    "}\n" +
                    ".headli1_1:hover{\n" +
                    "    background-color: #2F8AE3;\n" +
                    "    border-radius: 20px;\n" +
                    "    color: #ffffff;\n" +
                    "}\n" +
                    ".headli1_1:hover a{\n" +
                    "    color: #ffffff!important;\n" +
                    "}\n" +
                    ".headli1_1 a{\n" +
                    "    color: #444!important;\n" +
                    "}\n" +
                    ".headli1_1.one a{\n" +
                    "    color: #fff!important;\n" +
                    "}\n" +
                    ".head .headli2_1 {\n" +
                    "    width: 90px;\n" +
                    "    display: inline-block;\n" +
                    "    text-align: center;\n" +
                    "}\n" +
                    ".head .headli3 {\n" +
                    "    width: 90px;\n" +
                    "    display: inline-block;\n" +
                    "    text-align: center;\n" +
                    "    margin-top: 4px;\n" +
                    "}\n" +
                    ".clearfix:after{\n" +
                    "    content: '';\n" +
                    "    display: block;\n" +
                    "    clear: both;\n" +
                    "}\n" +
                    ".navigation {\n" +
                    "    heihgt: 70px;\n" +
                    "    display: inline-block;\n" +
                    "    float: left;\n" +
                    "    width: 100%;\n" +
                    "    /*margin-top: 47px;*/\n" +
                    "}\n" +
                    ".navigation .left {\n" +
                    "    float: left;\n" +
                    "    line-height: 71px;\n" +
                    "}\n" +
                    ".navigation .left img {\n" +
                    "    float: left;\n" +
                    "    margin-top: 19px;\n" +
                    "    margin-right: 5px;\n" +
                    "    padding-left: 30px;\n" +
                    "}\n" +
                    ".tr_td tbody tr:hover {\n" +
                    "    background-color: #D3E7FA;\n" +
                    "}\n" +
                    ".navigation .left .news {\n" +
                    "    /* font-size: 14px; */\n" +
                    "    margin-left: 2px;\n" +
                    "    font-family: \"微软雅黑\";\n" +
                    "    margin-top: -3px;\n" +
                    "    margin-right: 40px;\n" +
                    "    font-size: 20px;\n" +
                    "    color: #333;\n" +
                    "}\n" +
                    ".navigation .left div {\n" +
                    "    float: left;\n" +
                    "}\n" +
                    "tr{\n" +
                    "    border: 1px solid #c0c0c0;\n" +
                    "}\n" +
                    ".tr_td  tr:nth-child(odd){\n" +
                    "    background-color: #F6F7F9;\n" +
                    "}\n" +
                    "tr td {\n" +
                    "    font-size: 13px;\n" +
                    "}\n" +
                    "td {\n" +
                    "    color: #404060;\n" +
                    "    padding: 10px;\n" +
                    "    font: 14px \"微软雅黑\";\n" +
                    "}\n" +
                    ".th {\n" +
                    "    background-color: #fff;\n" +
                    "    font-size: 15px;\n" +
                    "    color: #2F5C8F!important;\n" +
                    "    font-weight: bold;\n" +
                    "    border: 0px;\n" +
                    "}\n" +
                    "#north{\n" +
                    "    position: fixed;\n" +
                    "    top:0;\n" +
                    "    left: 0;\n" +
                    "    background: #f5f5f5;\n" +
                    "    width:100%;\n" +
                    "}\n" +
                    ".th, td {\n" +
                    "    color: #404060;\n" +
                    "    padding: 10px;\n" +
                    "}\n" +
                    ".inp {\n" +
                    "    width: 200px;\n" +
                    "    height: 27px;\n" +
                    "    border-radius: 6px;\n" +
                    "    border:1px solid #ddd;\n" +
                    "    padding-left: 5px;\n" +
                    "    margin-left: 97px;\n" +
                    "}\n" +
                    ".inp:focus{\n" +
                    "    border-color: #00a0e9;\n" +
                    "}\n" +
                    ".import{\n" +
                    "    width: 70px;\n" +
                    "    height: 28px;\n" +
                    "    font-size: 13px !important;\n" +
                    "    cursor: pointer;\n" +
                    "    background-repeat: no-repeat;\n" +
                    "    background-image: url(../../img/sys/confirm.png);\n" +
                    "    padding-left: 25px;\n" +
                    "    border:none;\n" +
                    "}\n" +
                    ".exportsss{\n" +
                    "    width: 80px;\n" +
                    "    height: 30px;\n" +
                    "    font-size: 13px !important;\n" +
                    "    cursor: pointer;\n" +
                    "    background-repeat: no-repeat;\n" +
                    "    background-image: url(../../img/import.png);\n" +
                    "    padding-left: 25px;\n" +
                    "    border:none;\n" +
                    "}\n" +
                    ".importTwo{\n" +
                    "    width: 80px;\n" +
                    "    height: 30px;\n" +
                    "    font-size: 13px !important;\n" +
                    "    cursor: pointer;\n" +
                    "    background-repeat: no-repeat;\n" +
                    "    background-image: url(../../img/export.png);\n" +
                    "    padding-left: 9px;\n" +
                    "    border:none;\n" +
                    "    text-align: center;\n" +
                    "    line-height: 30px;\n" +
                    "    color: #444!important;\n" +
                    "}\n" +
                    "\n" +
                    ".cont_left {\n" +
                    "    border-right: 1px solid #000;\n" +
                    "    overflow-y: auto;\n" +
                    "    height: 100%;\n" +
                    "}\n" +
                    ".cont_left .dept_li {\n" +
                    "    display: block;\n" +
                    "    width: 86%;\n" +
                    "    padding-left: 30px;\n" +
                    "    font-size: 14px;\n" +
                    "    height: 40px;\n" +
                    "    line-height: 40px;\n" +
                    "    border-bottom: #ddd 1px solid;\n" +
                    "    cursor: pointer;\n" +
                    "}\n" +
                    ".cont_left .pick {\n" +
                    "    border-bottom: 1px solid #ddd;\n" +
                    "    padding-left: 12%;\n" +
                    "}\n" +
                    ".liUp {\n" +
                    "    background: url(../../img/sys/icon_rightarrow_03.png) no-repeat 91% center;\n" +
                    "}\n" +
                    ".cont_left .liUp:hover {\n" +
                    "    background-color: #add2f8;\n" +
                    "}\n" +
                    ".backCanBtn {\n" +
                    "    background-image: url(../../img/sys/return.png);\n" +
                    "    width: 70px;\n" +
                    "    height: 28px;\n" +
                    "    border:none;\n" +
                    "    text-align: center;\n" +
                    "    padding-left:27px;\n" +
                    "    font-style: 13px!important;\n" +
                    "}\n" +
                    ".cont_left .pick a {\n" +
                    "    font-size: 14px;\n" +
                    "    height: 40px;\n" +
                    "    line-height: 40px;\n" +
                    "    vertical-align: middle;\n" +
                    "}\n" +
                    ".liDown {\n" +
                    "    background: url(../../img/sys/icon_downarrow_03.png) no-repeat 91% center;\n" +
                    "}\n" +
                    ".trtd_d tbody tr td{\n" +
                    "    padding-top: 13px;\n" +
                    "    padding-bottom: 13px;\n" +
                    "}\n" +
                    "</style>\n";
}
